package com.example.weather;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class test extends AppCompatActivity {
    EditText et_url;
    TextView tv_show;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_htmlview_xutil);
        et_url = findViewById(R.id.et_url);
        et_url.setText("https://www.baidu.com");
        tv_show = findViewById(R.id.tv_show);
    }

    public void getHtml(View view) {
        RequestParams rp = new RequestParams(et_url.getText().toString().trim());
        x.http().get(rp,new MyCallBack());
    }
    public class MyCallBack implements Callback.CommonCallback<String>{

        @Override
        public void onSuccess(String result) {
            tv_show.setText(result);
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
        }

        @Override
        public void onCancelled(CancelledException cex) {

        }

        @Override
        public void onFinished() {
            System.out.println("完成");
        }
    }
}
